package src;

/**
 * ClassName: AriTest
 * Package: PACKAGE_NAME
 * Description:
 *
 * @Author xiao_qi
 * @Create 2023/11/27 19:37
 * @Version 1.0
 */
/*
测试运算符的使用1：算术运算符的使用


1. +  -  +  -  *  /  %  (前)++  (后)++  (前)--  (后)--  +


*/
public class AriTest {
    public static void main(String[] args) {
        int m1=12;
        int n1=5;
        int k=m1/n1;//2
        System.out.println("k="+k);//2
        System.out.println(m1/n1*n1);//10
//开发中，经常用来判断某个数num1能整除另外一个数num2。  num1 % num2 == 0
        //比如：判断num1是否是偶数： num1 % 2 == 0

        //结论：取模以后，结果与被模数的符号相同
        int j2=-12;
        int j3=5;
        int j4=j2%j3;
        System.out.println("j4="+j4);//-2

        int j5=12;
        int j6=-5;
        int j7=j5%j6;
        System.out.println("j7="+j7);//2

        //*******************************
        //(前)++ :先自增1，再运算
        //(后)++ :先运算，后自增1
        int a1 = 10;
        int b1 = ++a1;
        System.out.println("a1 = " + a1 + ",b1 = " + b1); //a1 = 11,b1 = 11

        int a2 = 10;
        int b2 = a2++;
        System.out.println("a2 = " + a2 + ",b2 = " + b2); //a2 = 11,b2 = 10
//同理--也一样样

        //强制转换类型
        short s1=10;
        //s1 += 1;
        //类型不同，编译不通过
        s1=(short)(s1+1);
        System.out.println(s1);
    }
}
